Skip to content

WHOOP HCI-capture extraction + CSV ground-truth correlation (#103)#133

Open
digitalerdude wants to merge 1 commit into
ryanbr:mainfrom
digitalerdude:whoop-export-pr
Open

WHOOP HCI-capture extraction + CSV ground-truth correlation (#103)#133
digitalerdude wants to merge 1 commit into
ryanbr:mainfrom
digitalerdude:whoop-export-pr

Conversation

@digitalerdude

@digitalerdude digitalerdude commented Jul 9, 2026

Copy link
Copy Markdown

What & why

Two stdlib tools in Tools/linux-capture/ that turn a WHOOP data export into leverage for cracking the un-decoded deep-record layouts from #103 (type-0x2F, 5/MG history types — see docs/WHOOP5_DEEP_DATA.md).

Importing this CSV format is already fully solved (including localized DE/ES headers, #3). The remaining gap per #103 is the decoding — and a personal export is exactly the known-plaintext material needed for that.

Tools

  • hci_extract.py — parses a phone Bluetooth HCI capture of the official app (iOS .pklg / Android btsnoop_hci.log), reassembles L2CAP/ATT, and emits the CRC-valid WHOOP frames in the project's own capture.json format. Only WHOOP streams make it into the output (other devices' frames are dropped). App writes are captured too, tagged dir:tx (the enable sequence).
  • correlate_ground_truth.py — known-plaintext field search. Cross-references capture records against the official per-night values from a WHOOP CSV export (HRV, resting HR, skin temperature, SpO₂, respiratory rate) and finds the byte offset + encoding + scale for each biometric. The localized header aliases are mirrored from the Swift importer (CSVParsing.swift). Distribution-overlap scoring (recall + precision) rejects constants and coincidental matches.

Privacy

Both tools run locally; correlate outputs only offsets/encodings, never health values. This lets 5/MG owners contribute a confirmed field mapping on #103 without posting their capture or data export.

Verification

  • Ran the full pipeline against a real German export (332 nights load cleanly): btsnoop log → hci_extract (331 type-47 frames) → correlate recovers resting HR (offset 10, u8) and skin temperature (offset 14, float32) exactly.
  • 25 new stdlib tests (btsnoop/pklg parsers, L2CAP/ATT reassembly, CSV aliases, planted-value recovery + false-positive rejection). Full suite: 129 green.

Mapped offsets still follow the project rule — real captures, never invented offsets — before landing in parseFrameWhoop5 / whoop_protocol.json.

🤖 Generated with Claude Code



Two stdlib tools in Tools/linux-capture that turn a WHOOP data export into
leverage for the un-decoded deep-record layouts tracked in ryanbr#103:

- hci_extract.py: parse a phone Bluetooth HCI capture (iOS .pklg /
  Android btsnoop) of the official app, reassemble L2CAP/ATT, and emit the
  CRC-valid WHOOP frames as the project's capture.json. Only WHOOP streams
  reach the output.
- correlate_ground_truth.py: known-plaintext field search. Cross-reference
  capture records against the official per-night values in a WHOOP CSV export
  (reusing the Swift importer's localized header aliases) to locate each
  biometric's byte offset + encoding. Distribution-overlap scoring (recall +
  precision) rejects constants and coincidences. Prints offsets only, so the
  output is safe to post on ryanbr#103 while health data stays local.

Docs: new README sections + a ground-truth-correlation note in
WHOOP5_DEEP_DATA.md. 25 new stdlib tests; full suite 129 green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sunny-noop

Copy link
Copy Markdown

Nice! Could you write your PR in English?

@digitalerdude

digitalerdude commented Jul 9, 2026

Copy link
Copy Markdown
Author

Done - description is now in English.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants